package org.springframework.samples.mvc.basic.session;

import java.util.HashMap;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
public class SessionDataHolderImpl implements SessionDataHolder {

	private Map<Class<? extends Object>, Object> map = new HashMap<Class<? extends Object>, Object>();

	@Override
	public <T> T getSessionDataFor(Class<T> clazz) {
		return (T) map.get(clazz);
	}

	@Override
	public <T> void setSessionData(Class<T> clazz, T object) {
		map.put(clazz, object);
	}
	
}
